export default {
    required: {
        rules: [{
            required: true,
            message: '不能为空',
        }]
    },
    isRequired: {
        rules: [{
            required: true,
            message: '不能为空且不能只输入空格',
        }, {
            whitespace: true,
            message: '不能只输入空格'
        }]
    },
    isNum: {
        rules: [{
            required: true,
            message: '必须为数字且不能为空',
        }, {
            type: 'number',
            message: '必须为数字且不能为空',
            transform: (value) => Number(value)
        }]
    },
    isAmount: {
        rules: [{
            required: true,
            message: '请最多保留两位小数',
            pattern: /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/,
            transform: (value) => Number(value)
        }]
    },
    isNumOrNull: {
        rules: [{
            type: 'number',
            required: false,
            message: '必须为数字',
            transform: (value) => Number(value)
        }]
    },
    isEmail: {
        rules: [{
            required: true,
            message: '必须为邮箱地址且不能为空',
        }, {
            type: 'email',
            message: '必须为邮箱地址且不能为空',
        }]
    },
    isEmailOrNull: {
        rules: [{
            type: 'email',
            message: '必须为邮箱地址',
        }]
    },
    isString: {
        rules: [{
            required: true,
            message: '必须为字符串且不能为空',
        }, {
            type: 'string',
            message: '必须为字符串且不能为空'
        }]
    },
    isStringOrNull: {
        rules: [{
            type: 'string',
            message: '必须为字符串'
        }]
    },
    isPhone: {
        rules: [{
            required: true,
            pattern: /^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}$/,
            message: '必须为移动电话号码',
        }]
    },
    isPhoneOrNull: {
        rules: [{
            required: false,
            pattern: /^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}$/,
            message: '必须为移动电话号码',
        }]
    },
    isFax: {
        rules: [{
            required: true,
            message: '必须为传真号码且不能为空',
            pattern: /^(\d{3,4}-)?\d{7,8}$/
        }]
    },
    isFaxOrNull: {
        rules: [{
            required: false,
            pattern: /^(\d{3,4}-)?\d{7,8}$/,
            message: '必须为传真号码',
        }]
    },
    isMobile: {
        rules: [{
            required: true,
            pattern: /^1[0-9]{10}$/,
            message: '必须为手机号码且不能为空',
        }]
    },
    isMobileOrNull: {
        rules: [{
            required: false,
            pattern: /^1[0-9]{10}$/,
            message: '必须为手机号码',
        }]
    },
    isMobileOrPhone: {
        rules: [{
            required: true,
            pattern: /^((0\d{2,3}-\d{7,8})|(1[34578]\d{9}))$/,
            message: '电话格式或手机格式',
        }]
    },
    isMobileOrPhoneOrNull: {
        rules: [{
            required: false,
            pattern: /^((0\d{2,3}-\d{7,8})|(1[34578]\d{9}))$/,
            message: '电话格式或手机格式或空',
        }]
    },
    isUri: {
        rules: [{
            required: true,
            message: '必须为网站地址且不能为空',
        }, {
            type: 'url',
            message: '必须为网站地址且不能为空'
        }]
    },
    isUriOrNull: {
        rules: [{
            type: 'url',
            message: '必须为网站地址',
        }]
    },
    cardNumber: {
        rules: [{
            required: true,
            pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
            message: '请输入正确的身份证格式',
        }]
    }
}

